package day06;
import java.util.Arrays;
public class exercise1 {
    public static void main(String[] args) {
        int[] arr1=new int[4];
        for (int i = 0; i <arr1.length ; i++) {
            arr1[i]=(int)(Math.random()*100);
            System.out.println(arr1[i]);
        }
        int max=arr1[0];
        for (int i = 1; i <arr1.length ; i++) {
            if (arr1[i]>max){
                max=arr1[i];
            }
        }
        System.out.println("最大值为"+max);

        arr1=Arrays.copyOf(arr1,arr1.length+1);//扩容
        arr1[arr1.length-1]=max;
        for (int i = 0; i < arr1.length; i++) {
            System.out.println(arr1[i]);
        }


        say();
        sayHi("许灵均", 34);
        System.out.println(getNum());
        int a1 = 5, a2 = 4;
        System.out.println(plus(a1, a2));

        int[] array=testArray(5,50);
        for (int i = 0; i <array.length ; i++) {
            System.out.print(array[i]+"\t");
        }


    }

    public static void say() {
        System.out.println("大家好，我叫许灵均");
    }

    public static void sayHi(String name, int age) {
        System.out.println("大家好，我叫" + name + "今年" + age + "岁了");
    }

    public static int getNum() {
        return 7;
    }

    public static int plus(int a, int b) {
        int c = a + b;
        return c;


    }

    public static int[] testArray(int count, int max) {
        int[] arr = new int[count];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * max);
        }
        return arr;
    }

}
